package com.automannn.websocketmqtt.websocketNodeB.restService;

import com.alibaba.fastjson.JSON;

import com.automannn.websocketmqtt.websocketNodeB.pubsub.provider.WsRedisPublisher;
import com.automannn.websoketmqtt.common.message.WsMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenkh
 * @time 2020/10/15 16:48
 */
@RestController
@RequestMapping("/ws")
public class RedisPublishHttpService {

    @Autowired
    private WsRedisPublisher publisher;

    @GetMapping("/sendWsMessage")
    public String send(){
        WsMessage wsMessage = new WsMessage();
        wsMessage.setTitle("myTitle");
        wsMessage.setSender("1");
        wsMessage.setContent("this is my content");
        wsMessage.setReceiver("3");
        publisher.publish("ws", JSON.toJSONString(wsMessage));
        return "ok";
    }
}
